<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table,
    th,
    td {
        border: 1px solid;
    }

    body {
        display: flex;
        justify-content: center;

        align-items: center;
        height: 600px;

        flex-direction: column;
    }
</style>

<body>
    <label>
        <h1>博客列表首页</h1>
    </label>
    <div>
        <input type="text" placeholder="请输入查找的id、标题、内容等关键字搜索" name="keyword">
        <input type="button" value="查找" onclick="query()"><input type="button" value="返回首页" onclick="back()">
        <input type="button" value="添加" onclick="add()">
    </div>

    <table id="tbData">
        <tr>
            <th>
                Id
            </th>
            <th>
                标题
            </th>
            <th>
                摘要
            </th>
            <th>
                内容
            </th>
            <th>
                分类
            </th>
            <th>
                作者
            </th>
            <th>
                操作
            </th>
        </tr>
    </table>


    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./config/configUrl.js"></script>
    <script src="./js/api.js"></script>
    <script src="./js/init.js"></script>

    <script>
        function update(id) {
            location.href = './addOrEdit.html?id=' + id;
        }
        function del(id) {
            let mag = '您确定删除该商品记录吗？'
            if (confirm(mag)) {
                delById(id).then(data => {
                    if (data.code === 1000) {
                        console.log(data);
                        let id = data.data.id;
                        $(`[key=${id}]`).remove();
                    }
                    else {
                        alert(data.msg)
                    }
                })
            }
            else {
                alert('您已取消了删除！')
            }
        }
        function query() {
            let keyword = $('[name=keyword]').val();
            getKeyword(keyword);
        }

        function add() {
            location.href = './addOrEdit.html';
        }

        function back() {
            location.href = './index.html';
        }
    </script>
</body>

</html>